<?php

class reportModel extends CModel {

    public $db;
    public static function get_data($data_arr)
    {
        //if(!isset($this->db))
        //{
            $this->db = Yii::app()->db->createCommand();
        //}
        $this->db->select($data_arr['select']);
	$this->db->from($data_arr['from']);
        if($data_arr['where']!='')
        {
            $this->db->where($data_arr['where'],$data_arr['params']);
        }
	       //  array('not in','network_level_status_log_value','passive'),
               // array('>=','date(network_level_status_log_datetime)',$start_daily)
        if(isset($data_arr['join']) AND trim($data_arr['join'])!='')
        {
            $this->db->join($data_arr['join'], $data_arr['params_join']);
        }
        
        if(isset($data_arr['group']) AND trim($data_arr['group'])!='')
        {
            $this->db->group($data_arr['group']);
        }
        if(isset($data_arr['order']) AND trim($data_arr['order'])!='')
        {
            $this->db->order($data_arr['order']);
        }

        return $this;
    }
    
}